unit RelatorioMovimentoEntradaSaidaEstoque;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, UFormRelatorio, DB, DBTables, StdCtrls, QRCtrls, QuickRpt,
  ExtCtrls;

type
  TFRelatorioMovimentoEntradaSaidaEstoque = class(TFormRelatorio)
    QRGProduto: TQRGroup;
    QRDBText1: TQRDBText;
    QRBand2: TQRBand;
    QRDBText3: TQRDBText;
    QRDBText4: TQRDBText;
    QRLabel5: TQRLabel;
    QRLabel6: TQRLabel;
    QRLabel7: TQRLabel;
    QRLabel8: TQRLabel;
    QRLabel9: TQRLabel;
    QRLabel10: TQRLabel;
    QRLabel11: TQRLabel;
    QRLabel12: TQRLabel;
    QRLabel13: TQRLabel;
    QRLabel14: TQRLabel;
    QRLabel15: TQRLabel;
    QRLabel16: TQRLabel;
    QRLabel17: TQRLabel;
    QRLabel18: TQRLabel;
    QRDBText5: TQRDBText;
    QRDBText6: TQRDBText;
    QRDBText7: TQRDBText;
    QRDBText8: TQRDBText;
    QRDBText9: TQRDBText;
    QRExpr1: TQRExpr;
    QRExpr2: TQRExpr;
    QRDBText10: TQRDBText;
    QRExpr3: TQRExpr;
    QRExpr4: TQRExpr;
    QRBand4: TQRBand;
    QRShape4: TQRShape;
    QRShape5: TQRShape;
    QRLEntrada: TQRLabel;
    QRLSaida: TQRLabel;
    QRShape7: TQRShape;
    QRLTotal: TQRLabel;
    QRDBText2: TQRDBText;
    QRLabel19: TQRLabel;
    QRLabel4: TQRLabel;
    procedure QRBand2BeforePrint(Sender: TQRCustomBand;
      var PrintBand: Boolean);
    procedure QRBand4BeforePrint(Sender: TQRCustomBand;
      var PrintBand: Boolean);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
   QTDEnt,QTDSai,QTDEntLOc,QTDSaiLOC :Real;
  end;

var
  FRelatorioMovimentoEntradaSaidaEstoque: TFRelatorioMovimentoEntradaSaidaEstoque;

implementation

uses UGeral, PesquisaMovimentoEntradaSaidaEstoque;

{$R *.dfm}

procedure TFRelatorioMovimentoEntradaSaidaEstoque.QRBand2BeforePrint(
  Sender: TQRCustomBand; var PrintBand: Boolean);
begin
  inherited;
 IF FPesquisaMovimentoEntradaSaidaEstoque.QPesquisa.FieldByName('TIPMOVEST_ENTRADASAIDA').AsString = planocontasEntrada then
  QTDEntLOc:=QTDEntLOc + FPesquisaMovimentoEntradaSaidaEstoque.QPesquisa.fieldByname('ITENSMOVEST_QUANTIDADE').AsFloat
 else
  QTDSaiLOC:=QTDSaiLOC + FPesquisaMovimentoEntradaSaidaEstoque.QPesquisa.fieldByname('ITENSMOVEST_QUANTIDADE').AsFloat;

end;

procedure TFRelatorioMovimentoEntradaSaidaEstoque.QRBand4BeforePrint(
  Sender: TQRCustomBand; var PrintBand: Boolean);
begin
  inherited;
 QRLEntrada.Caption:=FormatFloat('0.,00',QTDEntLOc);
 QRLSaida.Caption:=FormatFloat('0.,00',QTDSaiLOC);
 QRLTotal.Caption:=FormatFloat('0.,00',QTDEntLOc - QTDSaiLOC);
 QTDEntLOc:=0;
 QTDSaiLOC:=0;
end;

procedure TFRelatorioMovimentoEntradaSaidaEstoque.FormCreate(
  Sender: TObject);
begin
  inherited;
 QRelatorio.Close;
 QRelatorio.SQL.Clear;
 QRelatorio.SQL.Add('Select Emp_Razao as Razao from empresa ');
 QRelatorio.SQL.Add('Where Emp_Codigo = :Cod ');
 QRelatorio.ParamByName('Cod').AsInteger:=Codigoempresa;
 QRelatorio.Open;
 QRLNomeEmpresa.Caption:=QRelatorio.fieldByname('Razao').AsString;

end;

end.
